package com.itheima.demo;

import java.util.*;

public class Demo_Set {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"aaa","aaa","bbb","ccc","aaa","abc");
        //method(list);
        Set<String> set = new TreeSet<>();
        set.addAll(list);
        list.clear();
        list.addAll(set);
        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            String s = it.next();
            System.out.println(s);
        }
        System.out.println("===========================");

        for(String s : list){
            System.out.println(s);
        }

        System.out.println("===========================");

        Iterator<String> it1 = set.iterator();
        while (it1.hasNext()){
            System.out.println(it1.next());
        }
    }

    private static void method(ArrayList<String> list) {
        Set<String> set = new TreeSet<>();
        set.addAll(list);
        list.clear();
        list.addAll(set);
        System.out.println(list);
    }
}
